<?php


namespace app\api\model;


use think\Db;

class SubjectType extends BaseModel
{


    /***  关联SubjectCourse表
     * @return \think\model\relation\HasMany
     */
    public function SubjectCourse(){
        return $this->hasMany('SubjectCourse','content_type','id');
    }

    /***
     * @return \think\model\relation\HasMany
     */
    public function SubjectCourseLog(){
        return $this->hasMany('SubjectCourseLog','status','car_status');
    }

    /*** 关联查询分类的题
     * @param $Ids
     * @param $course
     * @param $car_status
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function SubjectCourseList($Ids,$course,$car_status){
        return self::with('SubjectCourse')
                    ->where('id',$Ids)
                    ->where('status',$car_status)
                    ->where('course',$course)
                    ->select();
    }
    

    /**
     * 获取分类列表
     * @param $course
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getTypeList($course,$condition){
        return  self::where('course','=',$course)
            ->where('status','in',$condition)
            ->select();
    }

    public function getSubjectList($course,$car_status){
        return self::with('SubjectCourse')
                        ->where('course',$course)
                        ->select();
    }



}